<?php
$str=curl('https://www.hc360.com/hots/900020772.html');
$str=iconv('gbk','UTF-8',$str);
//echo $str;
$preg='#<!--优品推荐-->.*<!--更多商机-->#isU';
preg_match($preg,$str,$arr);
//print_r($arr);die;
$preg1='#.*<li>.*<div class="proImg">.*<a onclick=".*" href="(.*)" target="_blank" title=".*">.*</a>.*</div>.*</li>#isU';
preg_match_all($preg1,$arr[0],$yy);
//print_r($yy);die;
//拼接
foreach($yy[1] as $k=>$v)
{
    $val='https:'.$v;
    echo $val;
  //联系我们的url
    $str=curl('https://b2b.hc360.com/supplyself/390806475.html');
    $str=iconv('gbk','UTF-8',$str);
//echo $str;
    $preg='#<div class="centerListBox">.*<div class="locationBox">#isU';
    preg_match($preg,$str,$arr);
//print_r($arr);die;
//$preg='#<td>.*<a onclick=".*"  href="(.*)" class=".*">(.*)</a>.*</td>#isU';
    $preg='#<div class="mainnav">.*<td><a onclick=".*" onmousedown=".*" data-useractivelogs=".*"   href="(.*)" class=".*" onmouseover=".*" onmouseout=".*" > 联系我们</a></td>.*<td class="navpitch"></td>.*<td class="navpitch"></td>.*</div>#isU';
    preg_match_all($preg,$arr[0],$arr_preg);
    foreach($arr_preg[1] as $k=>$v)
    {
        $val='https:'.$v;
        echo $val;die;

    }

}


//$str=curl('https://www.hc360.com/hots/900020772.html');
//$str1=curl('https://zhilicup.b2b.hc360.com/shop/company.html');
////echo $str1;
//$str1=iconv('gbk','UTF-8',$str1);
////echo $str1;
//$preg='#<div class="cConpanyName">.*<div class="contact3Btn">#isU';
//preg_match($preg,$str1,$arr);
////print_r($arr);die;
//$preg_arr='#<div class="cConpanyName">(.*)</div>.*<div class=".*">.*<em class=".*">.*</em>.*<span>联系人</span>：</div>.* <div class="con3Rig">.*<span>.*<a href=".*" .*>(.*)</a>&nbsp;&nbsp;（总经理）</span>.*</div>.*<div class="con3Left"><em class="telephoneIco"></em><span>电话</span>：</div>.*<div class="con3Rig" node-name="telephone">(.*)</div>.*<div class="con3Left"><em class="mobileIco"></em><span >手机</span>：</div>.*<div class="con3Rig" node-name="mp">(.*)</div>#isU';
//preg_match_all($preg_arr,$arr[0],$arr_preg);
////print_r($arr_preg);die;
//foreach($arr_preg[1] as $k=>$value)
//{
//    $preg_arr1['company_name']=$arr_preg[1][$k];
//    $preg_arr1['people_name']=$arr_preg[2][$k];
//    $preg_arr1['tel']=$arr_preg[3][$k];
//    $preg_arr1['phone']=$arr_preg[4][$k];
//    $dbh=new PDO('mysql:host=localhost;dbname=gaofei','root','root');
//    $sql="insert into company(company_name,people_name,tel,phone) VALUES('{$preg_arr1['company_name']}','{$preg_arr1['people_name']}','{$preg_arr1['tel']}','{$preg_arr1['phone']}')";
//    $dbh->exec($sql);
//
//}

function curl($url)
{
    $ch=curl_init();
    curl_setopt($ch,CURLOPT_URL,$url);
    curl_setopt($ch,CURLOPT_HEADER,0);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
    curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
    $str1=curl_exec($ch);
    return $str1;
}